
<template>
  <div>
    <avue-crud
      ref="crud"
      style="width: 100%"
      :data="loadData"
      :option="tableOption"
      :table-loading="loading"
    >
      <template slot="timeAndAddress" slot-scope="scope">
        <div
          v-if="
            scope.row.dateAndAddressDto
              ? scope.row.dateAndAddressDto.length
              : false
          "
        >
          <p v-for="(item, index) in scope.row.dateAndAddressDto" :key="index">
            <span v-if="item">
              {{ item.serviceDate }}
              {{ item.receiveAdress }}
            </span>
          </p>
        </div>
      </template>
      <template slot="menu" slot-scope="scope">
        <el-button type="text" icon="el-icon-check" @click="paiDan(scope.row)"
          >派单</el-button
        >
      </template>
    </avue-crud>
  </div>
</template>

<script>
import { tableOption } from "./servering.config.js";
import {
  workorderinfoMallQueryWallPerson,
  workorderinfoMallDispatchWall,
} from "@/api/shop/workorder/SuperCoffeeBar.js";
export default {
  data() {
    return {
      tableOption: tableOption,
      loading: false,
      loadData: [],
      ruleForm: {},
    };
  },
  methods: {
    getList(item) {
      this.ruleForm = item;
      workorderinfoMallQueryWallPerson(
        Object.assign({ subOrderId: item.subOrderId,shopId:item.shopId }, { isService: "01" })
      ).then((val) => {
        let data = val.data.data;
        this.loadData = data;
      });
    },
    paiDan(item) {
      console.log(" this.ruleForm：",this.ruleForm)
      console.log("item：",item)
      let obj = {
        businessType: this.ruleForm.businessType,
        personId: item.personId,
        subOrderId: this.ruleForm.subOrderId,
      };
      this.$confirm(
        "是否派单给服务人员名称为“ " + item.personName + " ”?",
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(() => {
          workorderinfoMallDispatchWall(obj)
            .then((val) => {
              this.$message.success("派单成功");
            })
            .catch(() => {
              return false;
            });
        })
        .catch(() => {
          return false;
        });
    },
  },
};
</script>